home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr46 / vfwdk.zip / VFWSDK.ZIP / SAMPLES / BRAVADO / LIBINIT.ASM < prev    next >
Assembly Source File  |  1993-01-31  |  5KB  |  181 lines

  1.         TITLE LIBINIT.ASM
  2.         page 60,132
  3.  
  4. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5. ;
  6. ; LIBINIT.ASM - 
  7. ;
  8. ;   General Description:
  9. ;      Library stub to do local init for a dynamic linked library.
  10. ;
  11. ;   Restrictions:
  12. ;      This must be the first object file in the LINK line.  This assures
  13. ;      that the reserved parameter block is at the *base* of DGROUP.
  14. ;
  15. ; (C) Copyright Microsoft Corp. 1992-1993.  All rights reserved.
  16. ;
  17. ; You have a royalty-free right to use, modify, reproduce and 
  18. ; distribute the Sample Files (and/or any modified version) in 
  19. ; any way you find useful, provided that you agree that 
  20. ; Microsoft has no warranty obligations or liability for any 
  21. ; Sample Application Files which are modified. 
  22. ;
  23. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  24.  
  25. if1
  26. %out link me first!!
  27. endif
  28.  
  29.         PMODE = 1
  30.  
  31.         .xlist
  32.         include cmacros.inc
  33.         .list
  34.         .286
  35.  
  36. ?PLM=1  ; Pascal calling convention
  37. ?WIN=0  ; Windows prolog/epilog code
  38.  
  39. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  40. ;
  41. ;   segmentation
  42. ;
  43. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  44.  
  45. ifndef SEGNAME
  46.     SEGNAME equ <_TEXT>
  47. endif
  48.  
  49. createSeg %SEGNAME, CodeSeg, word, public, CODE
  50.  
  51. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  52. ;
  53. ;   external functions
  54. ;
  55. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  56.  
  57.         externFP LocalInit           ; in KERNEL
  58.         externNP LibMain             ; C code to do DLL init
  59.  
  60. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  61. ;
  62. ;   data segment
  63. ;
  64. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  65.  
  66. sBegin Data
  67.  
  68.         assumes ds, Data
  69.  
  70. ; stuff needed to avoid the C runtime coming in, and init the Windows
  71. ; reserved parameter block at the base of DGROUP
  72.  
  73.         org 0               ; base of DATA segment!
  74.  
  75.         dd  0               ; so null pointers get 0
  76.  
  77. maxRsrvPtrs = 5
  78.         dw  maxRsrvPtrs
  79.  
  80. usedRsrvPtrs = 0
  81. labelDP <PUBLIC, rsrvptrs>
  82.  
  83. DefRsrvPtr  macro   name
  84.         globalW     name, 0
  85.         usedRsrvPtrs = usedRsrvPtrs + 1
  86. endm
  87.  
  88. DefRsrvPtr  pLocalHeap          ; local heap pointer
  89. DefRsrvPtr  pAtomTable          ; atom table pointer
  90. DefRsrvPtr  pStackTop           ; top of stack
  91. DefRsrvPtr  pStackMin           ; minimum value of SP
  92. DefRsrvPtr  pStackBot           ; bottom of stack
  93.  
  94. if maxRsrvPtrs-usedRsrvPtrs
  95.         dw maxRsrvPtrs-usedRsrvPtrs DUP (0)
  96. endif
  97.  
  98. public  __acrtused
  99.         __acrtused = 1
  100.  
  101. sEnd Data
  102.  
  103. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  104. ;
  105. ;   code segment
  106. ;
  107. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  108.  
  109. sBegin CodeSeg
  110.  
  111.         assumes cs, CodeSeg
  112.  
  113. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  114. ; LibEntry  - Called when DLL is loaded.
  115. ;
  116. ; CX    - Size of heap.
  117. ;
  118. ; DI    - Module handle.
  119. ;
  120. ; DS    - Automatic data segment.
  121. ;
  122. ; ES:SI - Address of command line (not used).
  123. ;
  124. ; Returns AX is TRUE if the load is successful and FALSE otherwise.
  125. ;
  126. ; Registers preserved are SI,DI,DS,BP.  Registers destroyed are
  127. ;       AX,BX,CX,DX,ES,FLAGS.
  128. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  129.  
  130.         assumes ds, nothing
  131.         assumes es, nothing
  132.  
  133. cProc LibEntry <FAR, PUBLIC, NODATA>, <>
  134. cBegin
  135.  
  136. ;
  137. ;   push frame for LibMain (hModule, cbHeap, lpszCmdLine)
  138. ;
  139.         push    di
  140.         push    cx
  141.         push    es
  142.         push    si
  143.  
  144. ;
  145. ; init the local heap (if one is declared in the .def file)
  146. ;
  147.         jcxz    no_heap
  148.  
  149.         cCall   LocalInit, <0, 0, cx>
  150.  
  151. no_heap:
  152.         cCall   LibMain
  153. cEnd
  154.  
  155. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  156. ; WEP    This function is called when the DLL is unloaded.
  157. ;
  158. ; wUselessParm    - This parameter has no meaning.
  159. ;
  160. ; WARNING: This function is basically useless since you can't call any
  161. ;     kernel function that may cause the LoadModule() code to be reentered.
  162. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  163.  
  164.         assumes ds, nothing
  165.         assumes es, nothing
  166.  
  167. cProc WEP <FAR, PUBLIC, NODATA>, <>
  168. ;       ParmW   wUselessParm
  169. cBegin nogen
  170.  
  171.         mov     ax, 1
  172.         retf    2
  173.  
  174. cEnd nogen
  175.  
  176.  
  177.  
  178. sEnd CodeSeg
  179.  
  180.         end LibEntry
  181.